/*
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
 *
 * Copyright (c) 2013-2014 jfinal app. jfapp Group.
 */

define(['adminapp'], function (mask,$app) {
    $app.navactive('ktv_booking');

    var $listtable = $app.listtable({
        'sAjaxSource' : g.ctx + "admin/ktv/booking/list",
        'bSort' : true,
        'bAutoWidth':true,
        'fnServerParams': function( aoData){
            var sd = $('#search_form').serializeJSON();
            $.each(sd, function(name, val){
                aoData.push({"name": name, "value": val});
            });
        },
        'aoColumns'   : [
            $app.checkall,
            $app.autono,
            {'mDataProp': 'booking_date'},
            {'mDataProp': 'name' ,"bSortable": false},
            {'mDataProp': 'phone' ,"bSortable": false},
            {'mDataProp': 'card_no' ,"bSortable": false},
            {'mDataProp': 'project_name' ,"bSortable": false},
            {'mDataProp': 'captcha' ,"bSortable": false},
            {'mDataProp': 'status' }
        ],
        'aoColumnDefs': [
            {
                'aTargets': [8],
                'mData'   : null,
                'mRender' : function (data, type, full) {
                    if(full['status']==1){
                        return '未到店';
                    }else if(full['status']==2){
                        return '已到店';
                    }else{
                        return '过期';
                    }
                }
            }
        ]
    }, 'data-list');

    $('#search_btn').on('click', function (e) {
        e.preventDefault();
        $listtable.fnReloadAjax();
    });
});